package com.cjgl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cjgl.model.dto.score.SelectScoresByTermOrCourseNameREquest;
import com.cjgl.model.entity.Coursestableview;
import com.cjgl.model.entity.TblCourses;
import com.cjgl.model.entity.TblStudents;
import com.cjgl.model.enums.SelectCourseOpenTypeEnum;
import com.cjgl.service.CoursestableviewService;
import com.cjgl.service.TblCoursesService;
import com.cjgl.service.TblStudentsService;
import com.cjgl.service.TblUsersService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class test {
	@Resource
	TblStudentsService studentsService;
	@Resource
	TblUsersService usersService;
	
	@Resource
	CoursestableviewService coursestableviewService;

	@Test
	public void tes() {
		List<TblStudents> tblStudents = studentsService.getBaseMapper().selectList(null);

		System.out.println(tblStudents);
	}

	@Test
	public void changePwd() {
//		Integer aBoolean = usersService.changeUserPassword("020301700070", "12345");
//
//		System.out.println(aBoolean);
		System.out.println(SelectCourseOpenTypeEnum.IS_OPEN.getValue());
	}



	@Test
	public void changeCo() {


		SelectScoresByTermOrCourseNameREquest coursesSelectCon = new SelectScoresByTermOrCourseNameREquest();
		coursesSelectCon.setAuthTime("2022-");
		String courseNo = coursesSelectCon.getCourseNo() == null ? "" : coursesSelectCon.getCourseNo();
		String courseName = coursesSelectCon.getCourseName() == null ? "" : coursesSelectCon.getCourseName();

		String ter = coursesSelectCon.getTer() == null ? "" : coursesSelectCon.getTer();
		String year = coursesSelectCon.getYear() == null ? "" : coursesSelectCon.getYear();
		String authTime = coursesSelectCon.getAuthTime() == null ? "" : coursesSelectCon.getAuthTime();

		String termSelect = ter + year;

		LambdaQueryWrapper<Coursestableview> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper
				.like(!StringUtils.isEmpty(courseNo), Coursestableview::getCourseNo, courseNo)
				.like(!StringUtils.isEmpty(courseName), Coursestableview::getCourseName, courseName)
				.like(!StringUtils.isEmpty(termSelect), Coursestableview::getTerm, termSelect)
				.like(!StringUtils.isEmpty(authTime), Coursestableview::getTeachingTime, "2022");
		List<Coursestableview> coursestableviewList = coursestableviewService.getBaseMapper().selectList(queryWrapper);
		System.out.println(coursestableviewList);
	}

	@Resource
	TblCoursesService coursesService;
	@Test
	public void getNotSelectedCourse() {
		List<TblCourses> notSelectedCourse = coursesService.getNotSelectedCourse("020301700070");
		notSelectedCourse.forEach(item-> System.out.println(item));
	}
}

